const ORI_BETCOUNT = 1
const BET_SPANCOUNT = 1

let Game = require('TxGame')
let {Global} = require('Global')


cc.Class({
    extends: cc.Component,
    properties: {
        displayCount: cc.Label,
        count: cc.Integer,
    },
    onLoad() {
        this.reset()
    },

    reset() {
        this.count = ORI_BETCOUNT
        this.displayCount.string = '本局押注:' + this.count.toString()
    },

    luckyClick() {

    },

    add() {
        let added = this.count + BET_SPANCOUNT
        if (added > Global.user.money) {
            Global.gameInstance.betNoEnoughMoney()
            return
        }
        if (added > Global.room.maxBetMoney) {
            return
        }
        this.count = added
        this.displayCount.string = '本局押注:' + this.count.toString()
    },

    confirm() {
        if (this.count > Global.user.money) {
            Global.gameInstance.betNoEnoughMoney()
            return
        }
        Global.gameInstance.confirmBet({ money: this.count })
    },

    cancel() {
        this.node.active = false
        Global.gameInstance.cancelBet()
    },

})